package com.example.demo.dto;

import com.example.demo.entity.RoleDepartmentUser;

public class RoleDepartmentUserDTO {
    private Integer id;
    private Integer roleConfigId;
    private String roleName;
    private Integer departmentId;
    private String departmentName;
    private Integer userId;
    private String userName;
    private Boolean isDefault;
    private String userAuthid;
    
    // 保留兼容性字段
    private String roleConfigName;  // 角色配置名称（兼容性字段）

    // 从实体类转换为DTO（使用冗余字段）
    public static RoleDepartmentUserDTO fromEntity(RoleDepartmentUser entity) {
        RoleDepartmentUserDTO dto = new RoleDepartmentUserDTO();
        dto.setId(entity.getId());
        dto.setRoleConfigId(entity.getRoleConfigId());
        dto.setRoleName(entity.getRoleName());
        dto.setDepartmentId(entity.getDepartmentId());
        dto.setDepartmentName(entity.getDepartmentName());
        dto.setUserId(entity.getUserId());
        dto.setUserName(entity.getUserName());
        dto.setIsDefault(entity.getIsDefault());
        dto.setUserAuthid(entity.getUserAuthid());
        // 设置兼容性字段
        dto.setRoleConfigName(entity.getRoleName());
        return dto;
    }
    
    // 从实体类转换为DTO（包含额外name信息，保留兼容性）
    public static RoleDepartmentUserDTO fromEntityWithNames(RoleDepartmentUser entity, 
                                                           String roleConfigName, 
                                                           String departmentName, 
                                                           String userName) {
        RoleDepartmentUserDTO dto = fromEntity(entity);
        // 如果传入了额外的名称信息，则覆盖冗余字段
        if (roleConfigName != null) {
            dto.setRoleConfigName(roleConfigName);
            dto.setRoleName(roleConfigName);
        }
        if (departmentName != null) {
            dto.setDepartmentName(departmentName);
        }
        if (userName != null) {
            dto.setUserName(userName);
        }
        return dto;
    }
    
    public Integer getId() {
        return id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    public Integer getRoleConfigId() {
        return roleConfigId;
    }
    
    public void setRoleConfigId(Integer roleConfigId) {
        this.roleConfigId = roleConfigId;
    }
    
    public String getRoleName() {
        return roleName;
    }
    
    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
    
    public Integer getDepartmentId() {
        return departmentId;
    }
    
    public void setDepartmentId(Integer departmentId) {
        this.departmentId = departmentId;
    }
    
    public String getDepartmentName() {
        return departmentName;
    }
    
    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }
    
    public Integer getUserId() {
        return userId;
    }
    
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
    
    public String getUserName() {
        return userName;
    }
    
    public void setUserName(String userName) {
        this.userName = userName;
    }
    
    public Boolean getIsDefault() {
        return isDefault;
    }
    
    public void setIsDefault(Boolean isDefault) {
        this.isDefault = isDefault;
    }
    
    public String getUserAuthid() {
        return userAuthid;
    }
    
    public void setUserAuthid(String userAuthid) {
        this.userAuthid = userAuthid;
    }
    
    public String getRoleConfigName() {
        return roleConfigName;
    }
    
    public void setRoleConfigName(String roleConfigName) {
        this.roleConfigName = roleConfigName;
    }
}